package com.ruoyi.base.service.impl;

import com.ruoyi.base.domain.Device;
import com.ruoyi.base.mapper.DeviceMapper;
import com.ruoyi.base.service.IDeviceService;
import com.ruoyi.display.domain.DeviceStateVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.UUID;

/**
 * 串口设备Service业务层处理
 *
 * @author ruoyi
 * @date 2024-06-03
 */
@Service
public class DeviceServiceImpl implements IDeviceService {
    @Autowired
    private DeviceMapper deviceMapper;

    /**
     * 查询串口设备
     *
     * @param id 串口设备主键
     * @return 串口设备
     */
    @Override
    public Device selectDeviceById(String id) {
        return deviceMapper.selectDeviceById(id);
    }

    /**
     * 查询串口设备列表
     *
     * @param device 串口设备
     * @return 串口设备
     */
    @Override
    public List<Device> selectDeviceList(Device device) {
        return deviceMapper.selectDeviceList(device);
    }

    /**
     * 新增串口设备
     *
     * @param device 串口设备
     * @return 结果
     */
    @Override
    public int insertDevice(Device device) {
        device.setId(UUID.randomUUID().toString());
        return deviceMapper.insertDevice(device);
    }

    /**
     * 修改串口设备
     *
     * @param device 串口设备
     * @return 结果
     */
    @Override
    public int updateDevice(Device device) {
        return deviceMapper.updateDevice(device);
    }

    /**
     * 批量删除串口设备
     *
     * @param ids 需要删除的串口设备主键
     * @return 结果
     */
    @Override
    public int deleteDeviceByIds(String[] ids) {
        return deviceMapper.deleteDeviceByIds(ids);
    }

    /**
     * 删除串口设备信息
     *
     * @param id 串口设备主键
     * @return 结果
     */
    @Override
    public int deleteDeviceById(String id) {
        return deviceMapper.deleteDeviceById(id);
    }

    @Override
    public DeviceStateVo selectDeviceState() {
        return deviceMapper.selectDeviceState();
    }

    @Override
    public void updateDeviceState(String cjqNo, Long online) {
        deviceMapper.updateDeviceState(cjqNo, online);
    }
}
